<template>
  <!-- 分发详情 - 弹窗 -->
  <a-modal
    :visible="true"
    title="详情"
    :footer="null"
    width="485px"
    class="distribute-detail-model"
    @cancel="dismiss"
  >
    <template #closeIcon>
      <svg-icon icon-class="icon_search_delete" class-name="icon-search-delete"></svg-icon>
    </template>
    <!-- 表格内容 -->
    <div class="info-content">
      <a-table
        :columns="columns"
        :data-source="dataSource"
        bordered
        :pagination="false"
        :scroll="{ y: 56 * 3 }"
      >
        <template #bodyCell="{ column, text }">
          <a-tooltip
            placement="top"
            :title="
              column.dataIndex === 'department'
                ? text?.length > 9
                  ? text
                  : ''
                : column.dataIndex === 'recipient'
                ? text?.length > 3
                  ? text
                  : ''
                : ''
            "
          >
            <div>
              <span v-if="column.dataIndex === 'processStatus'" class="state-bg">
                <svg-icon
                  :icon-class="stateIcons[parseInt(text ? text : '')]"
                  class-name="icon-state"
                />
                <span class="state-text">{{ stateTexts[parseInt(text ? text : '')] }}</span>
              </span>
              <span
                v-else
                :title="
                  column.dataIndex === 'department'
                    ? text?.length > 9
                      ? text
                      : ''
                    : column.dataIndex === 'recipient'
                    ? text?.length > 3
                      ? text
                      : ''
                    : ''
                "
                >{{ text ? text : '--' }}</span
              >
            </div>
          </a-tooltip>
        </template>
      </a-table>
    </div>
  </a-modal>
</template>
<script setup>
import { defineProps, defineEmits, ref } from 'vue';
const props = defineProps({
  recordId: {
    type: Number,
    default: 0
  }
});
const columns = [
  {
    title: '发往单位',
    dataIndex: 'department',
    width: '158px'
  },
  {
    title: '状态',
    dataIndex: 'state',
    width: '96px'
  },
  {
    title: '签收人',
    dataIndex: 'recipient',
    width: '74px'
  },
  {
    title: '签收日期',
    dataIndex: 'date',
    width: '102px'
  }
];

const dataSource = ref([]);
for (let i = 0; i < 5; i++) {
  dataSource.value.push({
    key: i.toString(),
    department: '校办公室',
    state: '审批中',
    recipient: '李慕雪',
    date: '2023-12-12'
  });
  dataSource.value.push({
    key: i.toString(),
    department: '校办公室校办公室',
    state: '审批中',
    recipient: '李慕雪雪',
    date: '2023-12-12'
  });
  dataSource.value.push({
    key: i.toString(),
    department: '校办公室校办公室校办',
    state: '审批中',
    recipient: '李慕雪雪',
    date: '2023-12-12'
  });
}
const stateIcons = ref({
  approving: 'form_icon_shenpizhong',
  processing: 'form_icon_banlizhong',
  completed: 'form_icon_yibanjie',
  rejected: 'form_icon_yibohui',
  revoked: 'form_icon_yichexiao'
});
const emit = defineEmits(['distributeDetailDismiss']);

function dismiss() {
  // console.log('dismiss');
  emit('distributeDetailDismiss');
}
</script>
<style lang="less">
.distribute-detail-model {
  top: 100px;
  .icon-search-delete {
    margin: 23px auto 0;
    width: 20px;
    height: 20px;
  }
  .ant-modal-content {
    width: 485px;
    height: 310px;
    border-radius: 6px;
    .ant-modal-header {
      display: flex;
      align-items: center;
      height: 66px;
      border-radius: 6px;
      border: 0;
      .ant-modal-title {
        font-size: 18px;
        font-family: Source Han Sans CN, Source Han Sans CN-Medium !important;
        font-weight: 500;
        color: rgba(0, 0, 0, 0.8);
      }
      .ant-modal-close {
        height: 66px !important;
      }
    }
    .ant-modal-body {
      padding: 0;
      .info-content {
        margin-left: 24px;
        width: 440px;
        height: 225px;
        // border-bottom: 0.5px solid #f0f0f0;
        overflow-y: hidden;
        .ant-table-thead .ant-table-cell {
          height: 55px;
          background-color: #f2f3f5;
          border-color: rgba(186, 191, 197, 0.4);
          font-size: 14px;
          font-family: Source Han Sans CN, Source Han Sans CN-Medium;
          font-weight: 500;
          text-align: LEFT;
          color: rgba(0, 0, 0, 0.8);
        }
        .ant-table-cell {
          padding: 5px 15px;
          border-color: rgba(186, 191, 197, 0.4);
          font-size: 14px;
          font-family: Source Han Sans CN, Source Han Sans CN-Medium;
          font-weight: 400;
          color: rgba(0, 0, 0, 0.8);
          height: 56px;
          vertical-align: middle;

          div {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            .state-bg {
              display: flex;
              align-items: center;
            }
            .icon-state {
              display: inline-block;
              width: 14px;
              height: 14px;
            }
            .state-text {
              margin-left: 3px;
              font-size: 12px;
              font-weight: 400;
              color: rgba(0, 0, 0, 0.6);
            }
          }
        }
      }
      .ant-table-tbody > tr.ant-table-row:hover > td {
        background: none !important;
      }
      ::-webkit-scrollbar {
        display: none;
      }
    }
  }
}
</style>
